﻿using GraphTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Drawing;
using System;
using GraphTest.Geometry2D;

namespace UTProject
{
    
    
    /// <summary>
    ///This is a test class for Geometry2DHelper_Test and is intended
    ///to contain all Geometry2DHelper_Test Unit Tests
    ///</summary>
    [TestClass()]
    public class Geometry2DHelper_Test
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        [TestMethod()]
        public void FindMinUncollisionShift_Test()
        {
            Rectangle2D r = new Rectangle2D(new Point2D(160.0F, 130.0F), new Vector2D(180.0F, 70.0F));
            Rectangle2D r0 = new Rectangle2D(new Point2D(60.0F, 210.0F), new Vector2D(120.0F, 50.0F));
            Vector2D shift = new Vector2D(140, -30);
            Vector2D expected = new Vector2D(46, -10);
            Vector2D actual = Geometry2DHelper.FindMaxUncollisionShift(r, r0, shift);
            
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.X, actual.X);
            Assert.AreEqual(expected.Y, actual.Y);
        }

        [TestMethod()]
        public void IsRectanglesIntersected_Test()
        {
            Rectangle2D r = new Rectangle2D(new Point2D(160.0F, 130.0F), new Vector2D(180.0F, 70.0F));
            Rectangle2D r0 = new Rectangle2D(new Point2D(230.0F, 80.0F), new Vector2D(40.0F, 140.0F));

            bool? acttual = r.IsRectanglesIntersected(r0);

            Assert.IsTrue(acttual.HasValue && acttual.Value);
        }
    }
}
